package com.wimcorp.magic.behaviour.attack;

import javax.persistence.Entity;

import com.wimcorp.magic.behaviour.attack.AttackBehaviour.AttackType;
import com.wimcorp.magic.cards.Creature;
import com.wimcorp.magic.players.Player;

@Entity
public class LifeLink extends AttackBehaviour{

	private static LifeLink instance = new LifeLink();

	protected LifeLink() {
		
	}
	
	public LifeLink(Creature creature,AttackBehaviour attackBehaviour) {
		super(creature,attackBehaviour);
	}
	
	public static LifeLink instance() {
		return instance;
	}
	
	protected void attack(Creature defender) {
		addLife();
		getAttackBehaviour().attack(defender);
	}
	
	@Override
	public void counter(Creature attacker) {
		addLife();
		getAttackBehaviour().counter(attacker);
	}

	protected void attack(Player defender) {
		addLife();
		getAttackBehaviour().attack(defender);
		
	}
	
	private void addLife() {
		getCreature().getPlayer().addLife(getCreature().getActualPower());
	}

	
	public int priority() {
		return AttackType.LIFELINK.ordinal();
	}
	
	public boolean equals(Object o){
		return o instanceof LifeLink;
	}

	
	
}
